package eerbaar.internal.action;

import java.util.HashMap;
import java.util.Map;

import eerbaar.action.IAction;
import eerbaar.action.IActionFactory;
import eerbaar.action.IActionService;
import eerbaar.context.IParams;

public class ActionService implements IActionService {

    private final Map<String, IActionFactory> controllers = new HashMap<String, IActionFactory>();

    @Override
    public IAction createAction(String name, IParams params) {

        IActionFactory f = this.controllers.get(name);
        assert (f != null) : "not found " + name;
        return f.create(params);
    }

    @Override
    public void registerAction(String name, IActionFactory contoller) {

        this.controllers.put(name, contoller);
    }

}
